<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>法援宝</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.css" />
    <link rel="stylesheet" type="text/css" href="../css/lawyer.css" />
    <script type="text/javascript" src="../script/api.js"></script>
    <script type="text/javascript" src="../script/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../script/mobile.js"></script>
    <script type="text/javascript" src="../script/lawyer.js"></script>
    <style type="text/css">
        .dashang {
            background: url("../image/jinbi.png") left center no-repeat!important;
            background-size: 0.3rem auto!important;
            font-size: 0.26rem;
            color: #f3a536!important;
            margin-right: 0.3rem;
        }
    </style>
</head>

<body>
    <div id="secHeader">
        <header class="header">
            <a href="javascript:void(0);" onclick="api.closeWin()" class="back_btn"><img src="../image/head-fanhui.png" alt=""></a>
            <h2 class="typeName">咨询广场</h2>
            <a href="javascript:;" onclick="commonUrl('myAnswer')" class="myAnswer_btn">我的回答</a>
        </header>
    </div>

    <section class="ask_square">
        <div class="ask_list">
            <ul id='con'>
                <!-- <li>
                <a href="javascript:;" onclick="aaplay('index','ask_details.html')">
                    <div class="userInfo">
                        <img src="../image/userimg1.jpg" alt="">
                        <div class="userName">
                            <h6>135****7574</h6>
                            <span>重庆 重庆市 <em>5小时前</em></span>
                        </div>
                    </div>
                    <div class="comment_info">
                        <p>我转租了一个门面，签合同的时候说明里面东西都归我，现在有人来说机器是他的，要求我归还，我是不是可以不给他？</p>
                    </div>
                    <div class="ask_kinds">
                        <span>合同纠纷</span>
                        <div class="ask_active">
                            <em class="answer_num">4人回答</em>
                            <p>我来回答</p>
                        </div>
                    </div>
                </a>
            </li> -->

            </ul>
        </div>
    </section>


</body>

<script>
    var page = 0;
    var typeid = 1;
    apiready = function() {
        $api.fixStatusBar($api.dom('#secHeader'));
        api.setStatusBarStyle({
            style: 'light'
        });
        //$api.fixStatusBar($api.dom('.header'));

        typeid = api.pageParam.typeid;

        if(typeid==2){
          $(".typeName").html('付费咨询')
        }
        console.log(JSON.stringify(typeid))

        api.addEventListener({
            name: 'scrolltobottom'
        }, function(ret, err) {
            toDoRequest();
        });


        toDoRequest();

        //下拉刷新
        api.setRefreshHeaderInfo({
            visible: true,
            bgColor: 'rgba(255,255,255,255)',
            textColor: '#666',
            textDown: '下拉刷新',
            textUp: '释放刷新'
        }, function(ret, err) {
            toDoRefresh();
        });


    };




    function toDoRequest() {
        page++;
        var p = {
            page: page,
            fask_type: typeid
        };
        api.ajax({
            url: webSiteUrl + '/app/public/fask',
            method: 'post',
            data: {
                values: p
            }
        }, function(ret, err) {
            api.hideProgress();
            //console.log(JSON.stringify(ret))
            if (ret.code == 200) {

                html = "";
                var dashang = '';
                var tj = ret.data;
                if (tj != null) {

                    for (var i = 0; i < tj.length; i++) {
                        if (ck(tj[i].icon)) {
                            var u = ''
                        } else {
                            var u = webSiteUrl
                        }
                        if (tj[i].reward_price != 0) {
                            dashang = '<em class="dashang">' + tj[i].reward_price + '元</em>';
                        } else {
                            dashang = '';
                        }
                        if(tj[i].private == 1){
                          html += '<li class="lock"><a href="javascript:;"><div class="userInfo"><img src="' + u + tj[i].icon + '" alt=""><div class="userName"><h6>' + tj[i].phone + '</h6><span><em style="top:0;">' + tj[i].time +
                              '</em></span></div></div><div class="comment_info" onclick="askdetail(' + tj[i].id + ')"><p>' + tj[i].content + '</p></div><div class="ask_kinds"><span>' + tj[i].ajtype + '</span><div class="ask_active">' +
                              dashang + '<em class="answer_num">' + tj[i].num + '人回答</em><p onclick="fanswer(' + tj[i].id + ')">我来回答</p></div></div></a></li>';
                        }else if(tj[i].reward_price > 0){
                          html += '<li><a href="javascript:;"><div class="userInfo"><img src="' + u + tj[i].icon + '" alt=""><div class="userName"><h6>' + tj[i].phone + '</h6><span><em style="top:0;">' + tj[i].time +
                              '</em></span></div></div><div class="comment_info" onclick="askdetail(' + tj[i].id + ')"><p>' + tj[i].content + '</p></div><div class="ask_kinds"><span>' + tj[i].ajtype + '</span><div class="ask_active">' +
                              dashang + '<em class="answer_num">' + tj[i].num + '人回答</em><p onclick="fanswer(' + tj[i].id + ')">我来回答</p></div></div></a></li>';
                        }else {
                          html += '<li><a href="javascript:;"><div class="userInfo"><img src="' + u + tj[i].icon + '" alt=""><div class="userName"><h6>' + tj[i].phone + '</h6><span><em style="top:0;">' + tj[i].time +
                              '</em></span></div></div><div class="comment_info" onclick="askdetail(' + tj[i].id + ')"><p>' + tj[i].content + '</p></div><div class="ask_kinds"><span>' + tj[i].ajtype + '</span><div class="ask_active">' +
                              dashang + '<em class="answer_num">' + tj[i].num + '人回答</em><p onclick="fanswer(' + tj[i].id + ')">我来回答</p></div></div></a></li>';
                        }



                    }
                }
                if (page == 1) {
                    $('#con').html(html);
                } else {
                    $('#con').append(html);
                }


            } else {
                if (page == 1) {
                    $('#con').html('<p style="text-align:center">暂无数据</p>');
                }

            }
        });

    }

    function fanswer(id) {
        if (!loginCheck()) {
            return false;
        }
        api.openWin({
            name: 'faskanswer',
            url: 'faskanswer.html',
            reload: true,
            pageParam: {
                id: id,

            }
        });
    }

    function askdetail(id) {
        api.openWin({
            name: 'faskdetail',
            url: 'faskdetail.html',
            reload: true,
            pageParam: {
                id: id,

            }
        });
    }

    function join(id) {

        api.openWin({
            name: 'faskdetail',
            url: 'faskdetail.html',
            pageParam: {
                id: id,

            }
        });
    }

    function aaplay(name, url) {
        api.openWin({
            name: name,
            url: url,
            pageParam: {

            }
        });
    }
</script>

</html>
